package com.miracle.feignclients;

import com.miracle.entity.Product;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

//调用商品服务的openFeign
@FeignClient(value = "productsClient") //当前接口是个feign组件, value：调用服务的id
public interface ProductClient {

    @GetMapping("/product/showMsg")
    String showMsg();

    @GetMapping("/product/findAll")
    Map<String, Object> findAll();

    //根据商品Id查询商品信息
    @GetMapping("/product/findOne") //使用openfeign的GET方式传递参数 参数变量必须通过@RequestParam进行修饰
    Map<String,Object> findOne(@RequestParam("productId") String productId);

    @PostMapping("/product/save")
    Map<String,Object> save(@RequestParam("name") String name);

    @PostMapping("/product/update")//使用openfeign传递对象信息，要求服务提供方和服务调用方都使用@RequestBody
    Map<String,Object> update(@RequestBody Product product);
}
